﻿using IBll;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HouseController : ControllerBase, IHouseBll
    {
        public HouseController(IHouseBll houseBll)
        {
            HouseBll = houseBll;
        }

        public IHouseBll HouseBll { get; }

        [HttpPost]
        public Task<int> AddAsync(House house)
        {
            return HouseBll.AddAsync(house);
        }
        [HttpDelete]
        public Task<int> DeleteAsync(int id)
        {
            return HouseBll.DeleteAsync(id);
        }
        [HttpGet]
        public dynamic GetHouses(string? name, int? typeid, int size, int index)
        {
            return HouseBll.GetHouses(name, typeid, size, index);   
        }
        [HttpPut]
        public Task<int> UpdateAsync(House house)
        {
            return HouseBll.UpdateAsync(house);
        }
    }
}
